home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / printfault.c < prev    next >
C/C++ Source or Header  |  1994-04-12  |  2KB  |  72 lines

  1. RCS_ID_C="$Id: printfault.c,v 3.2 1994/04/12 20:44:14 jraja Exp $";
  2. /* 
  3.  * printfault.c --- Print a socket error message (DOS)
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *                  All rights reserved.
  10.  *
  11.  * Created      : Sat Mar 20 02:10:14 1993 ppessi
  12.  * Last modified: Thu Feb  3 12:56:20 1994 ppessi
  13.  */
  14.  
  15. /****** net.lib/PrintNetFault ************************************************
  16.  
  17.     NAME
  18.         PrintNetFault - socket error messages
  19.  
  20.     SYNOPSIS
  21.         PrintNetFault(code, banner)
  22.         void PrintNetFault(LONG, const UBYTE *)
  23.  
  24.     FUNCTION
  25.         The PrintNetFault() function finds the error message corresponding
  26.         to the code and writes it, followed by a newline, to the standard
  27.         error or Output() filehandle. If the argument string is non-NULL it
  28.         is preappended to the message string and separated from it by a
  29.         colon and space (`: '). If string is NULL only the error message
  30.         string is printed.
  31.  
  32.     NOTES
  33.         The PrintNetFault() function uses the DOS IO functions.
  34.  
  35.     SEE ALSO
  36.         strerror(), perror(), <netinclude:sys/errno.h>
  37.  
  38. ******************************************************************************
  39. */
  40.  
  41. #include <errno.h>
  42. #include <clib/netlib_protos.h>
  43.  
  44. #include <exec/execbase.h>
  45. extern struct ExecBase *SysBase;
  46.  
  47. #include <dos/dos.h>
  48. #include <dos/dosextens.h>
  49.  
  50. #if __SASC
  51. #include <proto/dos.h>
  52. #elif __GNUC__
  53. #include <inline/dos.h>
  54. #endif
  55.  
  56. void 
  57. PrintNetFault(LONG code, const UBYTE *banner)
  58. {
  59.   struct Process *p = (struct Process *)SysBase->ThisTask;
  60.   BPTR Stderr = p->pr_CES ? p->pr_CES : p->pr_COS;
  61.   const UBYTE *err = strerror(errno);
  62.  
  63.   if (banner != NULL) {
  64.     FPuts(Stderr, banner);
  65.     FPuts(Stderr, ": ");
  66.   }
  67.   FPuts(Stderr, err);
  68.   FPuts(Stderr, "\n");
  69.   Flush(Stderr);
  70. }
  71.  
  72.